import type { EamEquipment } from "@/pages/eam/equipment/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
	//设备编码
	code?: string;
	//设备类型
	type?: number;
	//车间
	workshopId?: number;
	//资产编码
	resourceCode?: string;
	//机身编号
	machineCode?: string;
	//当前页码
	page: number;
	//每页数量
	pageSize: number;
}

export interface PageListRes {
	//总记录数
	total: number;
	//数据列表
	records: EamEquipment[];
}

const pageList = (data: PageListReq): Promise<PageListRes> =>
	apiClient.post({
		url: "/eam/equipment/pageList",
		data,
	});
const getInfo = (id: React.Key): Promise<EamEquipment> =>
	apiClient.get({
		url: `/eam/equipment/${id}`,
	});

const add = (data: EamEquipment): Promise<EamEquipment> =>
	apiClient.post({
		url: "/eam/equipment",
		data,
	});

const update = (data: EamEquipment): Promise<EamEquipment> =>
	apiClient.put({
		url: "/eam/equipment",
		data,
	});

const remove = (ids: React.Key[]): Promise<void> =>
	apiClient.delete({
		url: "/eam/equipment",
		params: {
			ids: ids.join(","),
		},
	});
export const eamEquipmentService = {
	pageList,
	getInfo,
	add,
	update,
	remove,
};

export default eamEquipmentService;
